<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<html>
<head>
<base href="<%=basePath%>" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>模板列表</title>
<script type='text/javascript' src='js/jquery-1.4.2.min.js'></script>
<script type='text/javascript' src='js/jquery.validate.min.js'></script>
<script type='text/javascript' src='js/common.js'></script>
<script type='text/javascript' src='dwr/engine.js'></script>
 <script type='text/javascript' src='dwr/util.js'></script>
 <script type='text/javascript' src='dwr/interface/bisGroupService.js'></script>
<script language="javascript" type="text/javascript" src="date/WdatePicker.js"></script>
<script type='text/javascript' src='js/jquery-ui-1.7.3.custom.min.js'></script>  
 <link href="style/ui-lightness/jquery-ui-1.7.3.custom.css" rel="stylesheet" type="text/css">
<link href="manage/manage.css" rel="stylesheet" type="text/css">
<script type="text/javascript"> 
   function search() {
	   $("#searchForm").submit();
   }

   function changeType() {
	   var t = $("#bisType").val();
	   bisGroupService.findGroupsByType(t, changeTypeHandler);
   }

   //预览
   function previewMsg(idx) {
	   $("#yulanDiv" + idx).dialog('open');
   }

   function editMsg(id) {
	   window.location.href = "mobanEditAction!editMoban.action?msgId=" + id;
   }

   function initYulan() {
		for ( var i = 0; i < 10; i++) {
		 var divHeight = $(".zhenshu" + $("#yulanDiv" + i).attr("msgid")).length * 240;
	   	 $("#yulanDiv" + i).dialog({title:"彩信预览", resizable:false,  width: divHeight,autoOpen: false});
		}
   }

   function delMsg(id) {
	   var r = window.confirm("确定要删除彩信模板吗?");
	   if (!r) {
		   return;
	   }
	   window.location.href = "mobanListAction!deleteMaybeSend.action?id=" + id;
   }
   
   function changeTypeHandler(data) {
	   DWRUtil.removeAllOptions("bisGroup");
	   DWRUtil.addOptions("bisGroup", [{"id":0,"name":"全部" }], "id", "name");
	   DWRUtil.addOptions("bisGroup", data, "id", "name"); 
   }

   function jumpPage(pageNo) {
	   $("#searchForm").attr("action", "mobanListAction!maybeSendList.action?pageNo=" + pageNo);
	   $("#searchForm").submit();
   }
   
</script>
</head>
<body style="margin:0px; text-align:center;font-size:12px;" bgcolor="#F1F1F1" >
<div id="top">
 	<!-- 头部-->
 	<%@include file="mainTop.jsp"%>
</div>
<div id="top2"></div>

<!-- 中间-->
<div id="main1">
<!-- 左边-->
 <%@include file="mainLeft.jsp"%>
 <div class="mainr2">
<table width="789" height="500" border="0" cellpadding="0" cellspacing="0" bgcolor="#F1F1F1">

  <tr>
    <td height="500" align="left" valign="top" s>
	<table width="788" height="70" border="0" cellpadding="0" cellspacing="0" style="border-bottom:1px solid #DBDBDB; border-left:1px solid #DBDBDB;  " >
      <tr style="font-size:12px">
        <td width="110" align="center"   background="images/line3.jpg" style="border:1px solid #DBDBDB;"><a href="mobanListAction!list.action">模板列表</a></td>
        <td width="7" style="border-bottom:1px solid #DBDBDB;">&nbsp;</td>
        
        <td width="110" align="center"   background="images/line3.jpg" style="border:1px solid #DBDBDB;"><a href="mobanAction!addMoban.action?first=1">新建模块</a></td>
        <td width="7" style="border-bottom:1px solid #DBDBDB;">&nbsp;</td>
        
		 	<td width="112" height="22" align="center"  background="images/line3.jpg" style="border:1px solid #DBDBDB;"><a href="bisType!allBisTypeListByName.action">模块分类</a></td>
        <td width="8" style="border-bottom:1px solid #DBDBDB;">&nbsp;</td>
        
       
      <td width="110" align="center"   background="images/line3.jpg" style="border:1px solid #DBDBDB;"><a href="bisGroup!allBisGroupListByName.action">模块分组</a></td>
        <td width="7" style="border-bottom:1px solid #DBDBDB;">&nbsp;</td> 
        
     <td width="112" height="22" align="center" bgcolor="#FFFFFF" style="border-top:1px solid #DBDBDB; border-right:1px solid #DBDBDB;" >还可能发送</td>
        <td width="322" style="border-bottom:1px solid #DBDBDB;">&nbsp;</td>
      </tr>
	  
      <tr>
        <td height="47" colspan="10" align="center" valign="top" style="border-right:1px solid #FFFFFF">
		<table width="780" height="42" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="font-size:12px">
          <tr  align="left">
            <td height="42"  valign="middle" class="STYLE20">
            <s:form name="searchForm" id="searchForm" action="mobanListAction!maybeSendList.action" method="post">
			 <table width="528" height="51" border="0" cellpadding="0" cellspacing="0" style="font-size:12px;" bgcolor="#FFFFFF">
				  <tr height="30px;">
                    <td width="94" align="right">增加时间：</td>
                    <td width="168" align="left">
						 <input type="text" style="width:155px;border:1px solid #DBDBDB;" value="<s:date name="startTime"  format="yyyy-MM-dd"/>" class="Wdate" name="startTime" id="startTime" onclick="WdatePicker()" />                   	
                    </td>
                    <td   align="center">至</td>
                    <td width="168" align="left">
						 <input type="text" style="width:155px;border:1px solid #DBDBDB;" value="<s:date name="endTime"  format="yyyy-MM-dd"/>"  class="Wdate" name="endTime" id="endTime" onclick="WdatePicker()" />                   	
                    </td>
                  </tr>
                  <tr height="30px;">
                    <td width="94" align="right">彩信分类：</td>
                    <td width="168" align="left">
						<s:select name="bisType" id="bisType"  onchange="changeType();" headerKey="0" headerValue="全部"
											list="allTypes" listKey="id" listValue="name"></s:select>
						</select>                    	
                    </td>
                    <td width="94" align="center">彩信分组：</td>
                    <td width="168" align="left">
						<s:select name="bisGroup" id="bisGroup" headerKey="0" headerValue="全部"
											list="allGroups" listKey="id" listValue="name"></s:select>
						</select>                    	
                    </td>
                  </tr>
                  
                  <tr height="30px;">
                  	<td width="94" align="right">彩信标题：</td>
                  	<td><s:textfield name="title" maxlength="30"></s:textfield></td>
                  	<td colspan="2" align="left">&nbsp;&nbsp;
                     <img src="images/ck.jpg" width="42" height="21" onclick="search();"> 
                  	</td>
                  </tr>
                  
                </table>		
				</s:form>
			    </td>
              </tr>
              
              <tr>
              		<td colspan="3">
              			<a href="mobanListAction!addMaybeSendSerach.action">&nbsp;&nbsp;&nbsp;&nbsp;添加还可能发送</a>
              		</td>
              		<td colspan="3"> </td>
              </tr>
            </table>          </td>
        </tr>
        </table>
        <s:if test="pageObj.data.size()>0"><!-- 如果有模块分组列表显示数据 -->
          <table width="787"  border="0" cellpadding="0" cellspacing="0" style="font-size:12px">
            <tr>
              <td width="186" height="29" align="center" background="images/lm1_bg.jpg">增加时间</td>
              <td width="11" background="images/lm1_bg.jpg"><img src="images/line2.jpg" width="10" height="25" /></td>
              <td width="251" align="center" background="images/lm1_bg.jpg">彩信标题</td>
              <td width="11" background="images/lm1_bg.jpg"><img src="images/line2.jpg" width="10" height="25" /></td>
              <td width="167" align="center" background="images/lm1_bg.jpg">彩信分类</td>
              <td width="11" align="center" background="images/lm1_bg.jpg"><img src="images/line2.jpg" width="10" height="25" /></td>
              <td width="150" align="center" background="images/lm1_bg.jpg">彩信分组</td>
              <td width="11" background="images/lm1_bg.jpg"><img src="images/line2.jpg" width="10" height="25" /></td>
              <td width="150" align="center" background="images/lm1_bg.jpg">操作</td>
            </tr>
             <!-- 开始数据显示 -->
            <s:iterator value="pageObj.data" var="msg" status="st">
            <s:if test="#st.odd"><tr bgcolor="#FFFFFF"></tr> </s:if>
            <s:else> <tr bgcolor="#F7F7F7"></s:else>
            
            <td height="30" align="center"><s:date name="#msg.addTime" format="yyyy-MM-dd HH:mm:ss"/></td>
              <td>&nbsp;</td>
              <td align="center"> <s:property value="#msg.title"/></td>
              <td>&nbsp;</td>
              <td align="center"><s:property value="#msg.bisType.name"/></td>
              <td>&nbsp;</td>
              <td align="center"><s:property value="#msg.bisGroup.name"/></td>
              <td align="center">&nbsp;</td>
              <td align="center">
              		<a href="javascript:previewMsg(${st.index}, ${msg.id });" >预览</a>&nbsp;
              		<a href="javascript:delMsg('${msg.id}');">删除</a>&nbsp;
              </td>
            </tr>
            
            </s:iterator>
            
			
            <tr>
            <s:if test="pageObj.totalRecord>10">
               <td height="29" align="right" background="images/lm1_bg.jpg" ><a href="javaScript:xinjiaBisGroup();" ></a></td>
              <td height="29" colspan="8" align="right" background="images/lm1_bg.jpg" >
              <a href="javascript:jumpPage(1)">首页</a>&nbsp;
                <s:if test="pageObj.hasPrePage==false" >上一页</s:if>
                <s:else> <a href="javascript:jumpPage(<s:property value="pageObj.pageNo-1"/>)">上一页</a></s:else>
   
              &nbsp;<s:if test="pageObj.hasNextPage==false">下一页</s:if>
              <s:else> <a href="javascript:jumpPage(<s:property value="pageObj.pageNo+1"/>)" >下一页</a></s:else>
              
              &nbsp; <s:if test="pageObj.pageNo==pageObj.totalPage">末页</s:if>
       <s:else><a href="javascript:jumpPage(<s:property value="pageObj.totalPage"/>)" >末页</a></s:else>

              
              &nbsp;&nbsp;第${pageObj.pageNo}页
              &nbsp;|&nbsp;共${pageObj.totalPage}页&nbsp;|&nbsp;共${pageObj.totalRecord}条 转至
            <s:select list="pageObj.listNum" onchange="jumpPage(this.value);" id="pageNo" name="pageNo">
            </s:select>
               </td>
               </s:if>
               <s:else> 
               <td height="29" colspan="6" background="images/lm1_bg.jpg" >&nbsp;</td>
                <td height="29"  align="center" background="images/lm1_bg.jpg"  > &nbsp;</td>
                <td height="29"  align="center" background="images/lm1_bg.jpg"  > &nbsp;</td>
                <td height="29"  align="center" background="images/lm1_bg.jpg"  > &nbsp;</td>
            </s:else>
            </tr>
      </table>
      </s:if>  
      <s:else><p style="color: red;font-size: 12px;text-align: center;">您还没有增加还可能发送的彩信的相关信息!</p></s:else>
      </td>
      </tr>
    </table></td>
  </tr>
</table></td>
  </tr>
</table></td>
  </tr>
</table></td>
  </tr>
 </div>

</div>

<s:iterator value="pageObj.data" var="msg" status="st">
<!-- 预览效果的div -->
<div id="yulanDiv${st.index}" msgid="${msg.id}" style="display: none;">
	<table cellspacing="0" cellpadding="0" border="0">
		<tr>
			<s:iterator var="item" value="manageMsgDetails">
			
			<td>
				<table cellspacing="0" cellpadding="0" border="0" width="216" height="424">
					        <tbody><tr>
					          <td align="center" width="216" valign="top" height="424"><table cellspacing="0" cellpadding="0" border="0" width="206" height="424">
					            <tbody><tr>
					              <td height="55" colspan="3"><img width="217" height="75" src="images/z_top.jpg"></td>
					            </tr>
					            <tr>
					              <td width="19" height="273"><img width="18" height="275" src="images/z_left.jpg"></td>
					              <td width="182" valign="top"><table cellspacing="0" cellpadding="0" border="0" align="center" width="181"  >
					                  <tbody><tr>
					                    <td width="185" height="140">
					                    	<s:if test="#item==null || #item.pic==null">
					                    		<img width="181" height="153" src="images/zlzjpg.jpg">
					                    	</s:if>
					                    	<s:else>
					                    		<img  width="181" height="153" src="<s:property value="#item.pic"/>" />
					                    	</s:else>
					                    </td>
					                  </tr>
					                  <tr>
					                    <td height="117">
					                    <s:if test="#item==null || #item.txt == null || #item.txt==''">
				                    		<textarea style="border:0px; height:115px;  width:181px; color:#000000;" disabled="disabled" cols="30" name="grjj">彩信文字内容</textarea>
				                    	</s:if>
				                    	<s:else>
						                    <textarea disabled="disabled" style="border:0px; height:115px;  width:181px; color:#000000;" cols="30" name="grjj"><s:property value="#item.txt"/></textarea>
					                    </s:else>
					                    
						          </td>
					                  </tr>
					              </tbody></table></td>
					              <td width="16"><img width="16" height="275" src="images/z_right.jpg"></td>
					            </tr>
					            <tr>
					              <td height="74" colspan="3"><img width="217" height="74" src="images/z_end.jpg"></td>
					            </tr>
					          </tbody></table></td>
					        </tr>
					      </tbody>
				</table>
			</td>
			</s:iterator>
			
		</tr>
		<tr>
			<s:iterator var="item2" value="manageMsgDetails">
			<td align="center" class="zhenshu${msg.id}">
				第${item2.zhenNo}帧
			</td>
			</s:iterator>
		</tr>
	</table>
</div>
</s:iterator>
<script type="text/javascript" defer="defer">
initYulan();
</script>
</body>
</html>
